/************************************************************************
Author:			Trey Turley, Thomas Lee, Marc Willis

Filename:		DriverDraw.cpp

Classname:		Plotter

Description:	The plotter class allows us to plot characters
				to the screen. It uses a coordinate system to
				determine where the character will be placed.

Date Modified:	8/3/10
				-	File created
*************************************************************************/


	//This currently prints a basic title followed
	//by the map and some basic directions.
	//It also has a basic loop setup that can be used to draw two different
	//Trails(Players) on the map. There is no bounds/collision detection in the test.
	//Need to look into pairing the plotter class with the players/AI.


#include <iostream>
using namespace std;
#include "plotter.h"
#include "keyboard.h"

int main()
{




//Main Title
	Plotter Title;
	Title.setColor(red);
	Title.move(40,5);
	cout<<"TRON";
	Title.move(40,6);
	cout<<"By:";
	Title.move(40,7);
	cout<<"Thomas Lee";
	Title.move(40,8);
	cout<<"Marc Willis";
	Title.move(40,9);
	cout<<"Trey Turley";
//Pause on opening screen
	Sleep(5000);
//clear it!
	Title.clear();

//Fill in map
	Plotter map;
	map.setColor(white);
	
	for(int a=0;a<80;a++)
	{
		for(int b=0;b<40;b++)
		{
			map.plot(a,b,SQUARE);
		}
	}

//Move cursor to bottom of map.
	map.move(0,41);

//Print some directions under the map
	Plotter Directions;
	Directions.setColor(white);
	cout<<"Directions for Tron: The goal is to trap your opponent."<<endl;
	cout<<"Try not to run into the walls or your opponent's trail."<<endl;


	
	

//Basic test to plot  player trails.
//It does not check to see if the player runs into themselves or
//If they go out of bounds. It is a basic test.
//Both players start at (0,0)

	//Players 1
	//Controls
	//UP=W, DOWN=S, LEFT=A, RIGHT=D

	Plotter Players;
	static int x=0,y=0;
	Players.setColor(blue);

	//Player 2
	//Controls
	//UP=Up Arrow, DOWN=Down Arrow, LEFT=Left Arrow, RIGHT=Right Arrow

	Plotter Players2;
	static int x2=0,y2=0;
	Players2.setColor(red);


//Press Q to quit out of the loop and end the testdriver

	while(!KEYDOWN(VK_KEY_Q))
	{
		if(KEYDOWN(VK_KEY_W))
		{
			y--;
			Players.plotTrail(x,y,blue);
		}
		if(KEYDOWN(VK_KEY_A))
		{
			x--;
			Players.plotTrail(x,y,blue);
		}
		if(KEYDOWN(VK_KEY_S))
		{
			y++;
			Players.plotTrail(x,y,blue);
		}
		if(KEYDOWN(VK_KEY_D))
		{
			x++;
			Players.plotTrail(x,y,blue);
		}	

//Player 2 Controls


		if(KEYDOWN(VK_UP))
		{
			y2--;
			Players.plotTrail(x2,y2,red);
		}
		if(KEYDOWN(VK_LEFT))
		{
			x2--;
			Players.plotTrail(x2,y2,red);
		}
		if(KEYDOWN(VK_DOWN))
		{
			y2++;
			Players.plotTrail(x2,y2,red);
		}
		if(KEYDOWN(VK_RIGHT))
		{
			x2++;
			Players.plotTrail(x2,y2,red);
		}	

		Sleep(50);
		
	}

	map.move(0,50);	

	return 0;
}
